package com.xiaoxu.intranetweb.mybatisplusSzappdb.controller.truck;

import cn.dev33.satoken.stp.StpUtil;
import com.xiaoxu.intranetweb.mybatisplusSzappdb.business.truck.TagBu;
import com.xiaoxu.intranetweb.mybatisplusSzappdb.dao.UserInfoDao;
import com.xiaoxu.intranetweb.util.PermissionCheck;
import com.xiaoxu.intranetweb.util.SzResult;
import com.xiaoxu.intranetweb.util.WebFunctionUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@RestController
@RequestMapping("/tag")
public class TagController {
    @Autowired
    private TagBu TagBu;
    @Autowired
    private UserInfoDao userInfoDao;
    @Autowired
    private WebFunctionUtil webFunctionUtil;
    //发放标签
    @GetMapping("/addTag")
    @PermissionCheck("tag_addTag")
    public SzResult addTag(@RequestParam String id,
                           @RequestParam String tag,
                           @RequestParam Integer value,
                           HttpServletRequest request) throws Exception {
        String token = request.getHeader("Authorization");
        String plantId = request.getHeader("Plant-Id");
        return TagBu.addTag(id, tag, value, token, plantId);
    }

    //删除标签
    @GetMapping("/deleteTag")
    @PermissionCheck("tag_deleteTag")
    public SzResult deleteTag(@RequestParam String id,
                              @RequestParam Integer value,
                              HttpServletRequest request) throws Exception {
        String token = request.getHeader("Authorization");
        String plantId = request.getHeader("Plant-Id");
        return TagBu.deleteTag(id, value, token, plantId);
    }

   /* //更换标签1
    @GetMapping("/updateTag1")
    public SzResult updateTag(@RequestParam String trucksTruckno,
                              @RequestParam String tag, HttpServletRequest request) throws Exception {
        String token = request.getHeader("Authorization");
        return TagBu.updateTag1(trucksTruckno, tag, token);
    }

    //更换标签2
    @GetMapping("/updateTag2")
    public SzResult updateTag2(@RequestParam String trucksTruckno,
                               @RequestParam String tag, HttpServletRequest request) throws Exception {
        String token = request.getHeader("Authorization");
        return TagBu.updateTag2(trucksTruckno, tag, token);
    }

    //更换标签3
    @GetMapping("/updateTag3")
    public SzResult updateTag3(@RequestParam String trucksTruckno,
                               @RequestParam String tag, HttpServletRequest request) throws Exception {
        String token = request.getHeader("Authorization");
        return TagBu.updateTag3(trucksTruckno, tag, token);
    }

    //删除标签1
    @GetMapping("/deleteTag1")
    public SzResult deleteTag1(@RequestParam String trucksTruckno, HttpServletRequest request) throws Exception {
        String token = request.getHeader("Authorization");
        return TagBu.deleteTag1(trucksTruckno, token);
    }

    //删除标签2
    @GetMapping("/deleteTag2")
    public SzResult deleteTag2(@RequestParam String trucksTruckno, HttpServletRequest request) throws Exception {
        String token = request.getHeader("Authorization");
        return TagBu.deleteTag2(trucksTruckno, token);
    }

    //删除标签3
    @GetMapping("/deleteTag3")
    public SzResult deleteTag3(@RequestParam String trucksTruckno, HttpServletRequest request) throws Exception {
        String token = request.getHeader("Authorization");
        return TagBu.deleteTag3(trucksTruckno, token);
    }*/
}
